<?php

function do_report_general($faculty_id) {

	include ('fen_fns.php');
	
	$user_id = $_SESSION['user_id'];
	

?>
	
	<script type="text/javascript">
	
		$(document).ready(function() {

			$(function() {
				$("a").click(function(){

				var value = $(this).attr('value');
			     
				$.ajax({
	            	type: 'GET',
	            	url: 'reports/users.php?did='+value,
	            	data: 'url=www.google.com.tr',	 
	            	beforeSend:function(){
	            	    // this is where we append a loading image
	            	    $('#users').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
	            	  },  
	            	success: function(ajaxCevap) {
	            		$('#users').html(ajaxCevap);
	            	}
	            });
			});
			});

			$(function() {


				$('#yayin_yili').change(function(){

			           
		            $.ajax({
		            	type: 'GET',
		            	url: 'reports/departments.php?uid=<?php echo $user_id; ?>&faculty_id=<?php echo $faculty_id; ?>&yid='+$(this).val(),
		            	data: 'url=www.google.com.tr',	 
		            	beforeSend:function(){
		            	    // this is where we append a loading image
		            	    $('#departments').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
		            	  },   
		            	success: function(ajaxCevap) {
		            		$('#departments').html(ajaxCevap);
		            	}
		            });

		        });

		        $('#makale_turu').change(function(){

			           
		            $.ajax({
		            	type: 'GET',
		            	url: 'reports/articles.php?<?php if ($faculty_id) { echo "fid=".$faculty_id."&"; } ?>did='+$(this).val(),
		            	data: 'url=www.google.com.tr',	 
		            	beforeSend:function(){
		            	    // this is where we append a loading image
		            	    $('#articles').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
		            	  },   
		            	success: function(ajaxCevap) {
		            		$('#articles').html(ajaxCevap);
		            	}
		            });

		        });

		        
		    });

			$.ajax({
            	type: 'GET',
            	url: 'reports/articles.php?<?php if ($faculty_id) { echo "fid=".$faculty_id."&"; } ?>did=0',
            	data: 'url=www.google.com.tr',	 
            	beforeSend:function(){
            	    // this is where we append a loading image
            	    $('#articles').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
            	  },  
            	success: function(ajaxCevap) {
            		$('#articles').html(ajaxCevap);
            	}
            });

			$.ajax({
            	type: 'GET',
            	url: 'reports/departments.php?yid=0&uid=<?php echo $user_id; ?>&faculty_id=<?php echo $faculty_id; ?>',
            	data: 'url=www.google.com.tr',	 
            	beforeSend:function(){
            	    // this is where we append a loading image
            	    $('#departments').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
            	  },  
            	success: function(ajaxCevap) {
            		$('#departments').html(ajaxCevap);
            	},
                error: function(XMLHttpRequest, textStatus, errorThrown) { 
                    alert("Status: " + textStatus); alert("Error: " + errorThrown); 
                } 
            });
			
		});

	</script>
	
	<div class="contentMain">

	
		<div class="showtable">
			<br><br>
			<div class="summaryTableSmall2">
				<div class="summaryTableSmallDepartmentTop">
					<p>Bölümlere Göre Yayın Sayıları</p>
					<select class="selectShortDepartment" type="text" name="yayin_yili" id="yayin_yili">
						<option value="0">Tüm yıllar...</option>
						<option value="2014">2014</option>
						<option value="2013">2013</option>
						<option value="2012">2012</option>
						<option value="2011">2011</option>
						<option value="2010">2010</option>
						<option value="2009">2009</option>
					</select>
				</div>
				<div class="summaryTableSmall2Middle">
	
						<div id="departments"></div>
						
						
					
				</div>
				<div class="summaryTableSmallBottom">
				</div>
			</div>
			<div id="space">&nbsp;</div>
			<div class="summaryTableSmall2">

				<div class="summaryTableSmallArticleTop">
					<p>Makale İstatistikleri</p>
					<select class="selectShortDepartment" type="text" name="makale_turu" id="makale_turu">
						<option value="0">Tüm Bölümler...</option>
					
<?php
						if ($faculty_id) {
							$query = $_DB->Query("SELECT * from fen_department where faculty_id = '".$faculty_id."' ORDER BY department_name ASC");
						} else {
							$query = $_DB->Query("SELECT * from fen_department where faculty_id = (select faculty_id from fen_members where fen_members.id = '".$_SESSION['user_id']."') ORDER BY department_name ASC");
						}
						
						$count = $_DB->GetResultNumber($query);	

						for ($i=0; $i<$count; $i++) {
							echo "<option value=\"".$_DB->GetResultValue($query, $i, "id")."\">".$_DB->GetResultValue($query, $i, "department_name")."</option>";
							
						}
?>					

					</select>
				</div>
				<div class="summaryTableSmall2Middleb">
						
						<div id="articles"></div>
						
				</div>
				<div class="summaryTableSmallBottom">
				</div>
				
				
			</div>
			
			<div id="users"></div>

		</div>	
		
	</div>

<?php
}

function do_report_detailed($userid) {


	include ('fen_fns.php');
	
?>
	
	<script type="text/javascript">

	var oTable;

	$(document).ready(function()
		{
		$(".faculty_id").change(function()
		{
		var id=$(this).val();
		var dataString = 'id='+ id;
		
		$.ajax
			({
			type: "POST",
			url: "reports/ajaxdepartments.php",
			data: dataString,
			cache: false,
			success: function(html)
			{
			$(".department_id").html(html);
			} 
			});
		});
	});

	$(document).ready(function() {

			

		$.ajaxSetup({
	        beforeSend: function(xhr, status) {
	            // TODO: show spinner
	            $('.spinner').show();
	        },
	        complete: function() {
	            // TODO: hide spinner
	            $('.spinner').hide();
	        }
	    });

	    $('#form form').submit(function(){
		        $('#reportResult').load('reports/getreport.php', {
			        'faculty_id': $('select[name="faculty_id"]').val(),
			        'department_id': $('select[name="department_id"]').val(),
			        'eser_adi': $('input[name="eser_adi"]').val(),
			        'name': $('input[name="name"]').val(),
			        'surname': $('input[name="surname"]').val(),
			        'yayin_tipi': $('select[name="yayin_tipi"]').val(),
			        'yayin_turu': $('select[name="yayin_turu"]').val(),
			        'yayin_yili_baslangic': $('select[name="yayin_yili_baslangic"]').val(),
			        'yayin_yili_bitis': $('select[name="yayin_yili_bitis"]').val(),
			        'indeks_turu': $('select[name="indeks_turu"]').val(),
			        'sinif': $('select[name="sinif"]').val()
			    });  
			          
		        $(".contentTopArea").hide();             
		        return false;
		});

<?php 

	if ($userid > 0) {

?>		
		$('#reportResult').load('reports/getreport.php', {
		    'user_id': '<?php echo $userid; ?>'
		});  
		      
		$(".contentTopArea").hide();             
		return false;


<?php
	}


?>	    
	});
	
	</script>
	<div class="contentTop">
		<div class="contentTopArea">
			<div id="formdiv">
				
				<p class="contentMainP">Arama Kriterleri</p>
				<hr noshade>
				
				<div id="form">
				
				<form>
<?php 
	if ($_SESSION['access_level'] != 50) {
	
?>				
				<label for="form1">Fakülte:</label>
				<select type="text" name="faculty_id" class="faculty_id">
				<option value="">Tüm Fakülteler</option>
<?php 
				$query = $_DB->Query("SELECT * from fen_faculty ORDER BY faculty_name ASC");
				$count = $_DB->GetResultNumber($query);
	
				for ($i=0; $i<$count; $i++)
				{
					if ($faculty_id == $_DB->GetResultValue($query, $i, "id")) {
						$selected = "selected";
					} else {
						$selected = "";
					}
					
					echo "<option value=\"".$_DB->GetResultValue($query, $i, "id")."\" ".$selected.">".$_DB->GetResultValue($query, $i, "faculty_name")."</option>";
				}
?>			
				</select><br>
<?php 
	}
?>
				<label for="form1">Bölüm:</label>
				<select type="text" name="department_id" class="department_id">
				<option value="">Tüm Bölümler</option>
<?php 
	if ($_SESSION['access_level'] == '50') {
		
		$query = $_DB->Query("SELECT * from fen_department WHERE faculty_id = (select faculty_id from fen_members where id = '".$_SESSION['user_id']."') ORDER BY department_name ASC");
		$count = $_DB->GetResultNumber($query);

		for ($i=0; $i<$count; $i++)
		{
		echo "<option value=\"".$_DB->GetResultValue($query, $i, "id")."\">".$_DB->GetResultValue($query, $i, "department_name")."</option>";
		}
		
	}
?>
				</select><br>
								
				<label for="form1">Eser Adı:</label> <input type="text" id="eser_adi" name="eser_adi" value=""><br>
				
				<label for="form1">Öğretim Üyesi Adı:</label> <input type="text" id="name2" name="name"><br>
				
				<label for="form1">Soyadı:</label> <input type="text" id="surname" name="surname"><br>
				
				<label for="form1">Yayın Tipi:</label>
				<select class="selectShort" type="text" name="yayin_tipi" id="yayin_tipi">
					<option value="">Tümü</option>
					<option value="Makale">Makale</option>
					<option value="Kitap Bölümü">Kitap Bölümü</option>
					<option value="Kitap">Kitap</option>
				</select><br>
				
				<label for="form1">Yayın Türü:</label>
				<select class="selectShort" type="text" name="yayin_turu" id="yayin_turu">
					<option value="">Tümü</option>
					<option value="Ulusal">Ulusal</option>
					<option value="Uluslararası">Uluslararası</option>
				</select><br>

				<label for="form1">Yayın Yılı:</label> 
				<select class="selectShort" type="text" id="yayin_yili_baslangic" name="yayin_yili_baslangic">
					
					<?php
					
					for ($i=0; $i<14; $i++) {
						$year = 2014 - $i;
						
						echo "<option value=\"".$year."\" ".$yearselected.">".$year."</option>";
					}
					
					?>	
					<option value="2000" selected>2000</option>	
				</select>
				&nbsp;<font color="#0289c5">-</color>&nbsp;
				<select class="selectShort" type="text" id="yayin_yili_bitis" name="yayin_yili_bitis">
					<option value="2014">2014</option>
					<?php
					
					for ($i=1; $i<15; $i++) {
						$year = 2014 - $i;
						
						echo "<option value=\"".$year."\" ".$yearselected.">".$year."</option>";
					}
					
					?>		
				</select>
				<br>
				
				<label for="form1">İndeks Türü:</label>
				<select class="selectShort" type="text" id="indeks_turu" name="indeks_turu">
					<option value="" selected>Tümü</option>
					<option value="SCI">SCI</option>
					<option value="SCIE">SCIE</option>
					<option value="SSCI">SSCI</option>
					<option value="AHCI">AHCI</option>
					<option value="Alan">Alan</option>
					<option value="Diger">Diğer</option>
				</select><br>
				
				<label for="form1">Dergi Grubu:</label>
				<select class="selectShort" type="text" id="sinif" name="sinif">
					<option value="" selected>Tümü</option>
					<option value="A">A</option>
					<option value="B">B</option>
					<option value="C">C</option>
					<option value="D">D</option>
					<option value="Diger">Diğer</option>
				</select><br><br>
			
				<input id="buttonSaveNew" type="submit" value="Ara">
				</form>
				</div>
				<br><br>
			
			</div>
		</div>
	</div>
	<div class="contentMain">

		<div id="reportResult"><img src="images/spinner.gif" class="spinner" alt="loading..." style="display: none;"></div>
		<br><br><br><br><br><br></div>
		
	</div>

<?php
}

function do_report_rectorate() {

	include ('fen_fns.php');

	?>
	
	<script type="text/javascript">
	
		$(document).ready(function() {

			$(function() {
				$("a").click(function(){

				var value = $(this).attr('value');
			     
				$.ajax({
	            	type: 'GET',
	            	url: 'reports/reports.php?did='+value,
	            	data: 'url=www.google.com.tr',	 
	            	beforeSend:function(){
	            	    // this is where we append a loading image
	            	    $('#users').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
	            	  },  
	            	success: function(ajaxCevap) {
	            		$('#users').html(ajaxCevap);
	            	}
	            });
			});
			});

			$(function() {


				$('#yayin_yili').change(function(){

			           
		            $.ajax({
		            	type: 'GET',
		            	url: 'reports/faculties.php?yid='+$(this).val(),
		            	data: 'url=www.google.com.tr',	 
		            	beforeSend:function(){
		            	    // this is where we append a loading image
		            	    $('#faculties').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
		            	  },   
		            	success: function(ajaxCevap) {
		            		$('#faculties').html(ajaxCevap);
		            	}
		            });

		        });

		        $('#makale_turu').change(function(){

			           
		            $.ajax({
		            	type: 'GET',
		            	url: 'reports/articles-faculty.php?did='+$(this).val(),
		            	data: 'url=www.google.com.tr',	 
		            	beforeSend:function(){
		            	    // this is where we append a loading image
		            	    $('#articles').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
		            	  },   
		            	success: function(ajaxCevap) {
		            		$('#articles').html(ajaxCevap);
		            	}
		            });

		        });

		        
		    });

			$.ajax({
            	type: 'GET',
            	url: 'reports/articles-faculty.php?&did=0',
            	data: 'url=www.google.com.tr',	 
            	beforeSend:function(){
            	    // this is where we append a loading image
            	    $('#articles').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
            	  },  
            	success: function(ajaxCevap) {
            		$('#articles').html(ajaxCevap);
            	}
            });

			$.ajax({
            	type: 'GET',
            	url: 'reports/faculties.php?yid=0',
            	data: 'url=www.google.com.tr',	 
            	beforeSend:function(){
            	    // this is where we append a loading image
            	    $('#faculties').html('<div class="loading"><img src="images/spinner.gif" alt="Loading..." /></div>');
            	  },  
            	success: function(ajaxCevap) {
            		$('#faculties').html(ajaxCevap);
            	}
            });
			
		});

	</script>
	
	<div class="contentMain">

	
		<div class="showtable">
			<br><br>
			<div class="summaryTableSmall2">
				<div class="summaryTableSmallDepartmentTop">
					<p>Fakültelere Göre Yayın Sayıları</p>
					<select class="selectShortDepartment" type="text" name="yayin_yili" id="yayin_yili">
						<option value="0">Tüm yıllar...</option>
						<option value="2014">2014</option>
						<option value="2013">2013</option>
						<option value="2012">2012</option>
						<option value="2011">2011</option>
						<option value="2010">2010</option>
						<option value="2009">2009</option>
					</select>
				</div>
				<div class="summaryTableSmall2Middle">
				
						<div id="faculties"></div>
	
						
					
				</div>
				<div class="summaryTableSmallBottom">
				</div>
			</div>
			<div id="space">&nbsp;</div>
			<div class="summaryTableSmall2">

				<div class="summaryTableSmallArticleTop">
					<p>Makale İstatistikleri</p>
					<select class="selectShortDepartment" type="text" name="makale_turu" id="makale_turu">
						<option value="0">Tüm Fakülteler...</option>
					
<?php
						$query = $_DB->Query("SELECT * from fen_faculty where type = '1' ORDER BY faculty_name ASC");
						$count = $_DB->GetResultNumber($query);	

						for ($i=0; $i<$count; $i++) {
							echo "<option value=\"".$_DB->GetResultValue($query, $i, "id")."\">".$_DB->GetResultValue($query, $i, "faculty_name")."</option>";
							
						}
?>					

					</select>
				</div>
				<div class="summaryTableSmall2Middleb">
						
						<div id="articles"></div>
						
				</div>
				<div class="summaryTableSmallBottom">
				</div>
				
				
			</div>
			
			<div id="users"></div>

		</div>	
		
	</div>

<?php
}

// TOPLANTI RAPORLARI

function do_toplanti_report_detailed() {


	include ('fen_fns.php');

	?>
	
	<script type="text/javascript">

	var oTable;

	$(document).ready(function()
		{
		$(".faculty_id").change(function()
		{
		var id=$(this).val();
		var dataString = 'id='+ id;
		
		$.ajax
			({
			type: "POST",
			url: "reports/ajaxdepartments.php",
			data: dataString,
			cache: false,
			success: function(html)
			{
			$(".department_id").html(html);
			} 
			});
		});
	});

	$(document).ready(function() {

			

		$.ajaxSetup({
	        beforeSend: function(xhr, status) {
	            // TODO: show spinner
	            $('.spinner').show();
	        },
	        complete: function() {
	            // TODO: hide spinner
	            $('.spinner').hide();
	        }
	    });

	    $('#form form').submit(function(){
		        $('#reportResult').load('reports/getmeetings.php', {
			        'faculty_id': $('select[name="faculty_id"]').val(),
			        'department_id': $('select[name="department_id"]').val(),
			        'name': $('input[name="name"]').val(),
			        'surname': $('input[name="surname"]').val(),
			        'toplanti_adi': $('input[name="toplanti_adi"]').val(),
			        'ulke': $('select[name="ulke"]').val(),
			        'tarih1': $('input[name="tarih1"]').val(),
			        'tarih2': $('input[name="tarih2"]').val(),
			        'bildiri_konusu': $('input[name="bildiri_konusu"]').val(),
			        'destek_turu': $('select[name="destek_turu"]').val(),
			        'ders_durumu': $('select[name="ders_durumu"]').val()
			    });  
			          
		        $(".contentTopArea").hide();             
		        return false;
		});

<?php 

	if ($userid > 0) {

?>		
		$('#reportResult').load('reports/getreport.php', {
		    'user_id': '<?php echo $userid; ?>'
		});  
		      
		$(".contentTopArea").hide();             
		return false;


<?php
	}


?>	    
	});

	  $(function() {
	    $( "#tarih1" ).datepicker({
	    	monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
	 	    monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz','Tem','Ağu','Eyl','Eki','Kas','Ara'],
	 	    dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
	 	    dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
	 	    dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
	        defaultDate: "+1w",
	        changeMonth: true,
	        numberOfMonths: 3,
	        dateFormat: 'dd/mm/yy',
	        onClose: function( selectedDate ) {
	        $( "#tarih2" ).datepicker( "option", "minDate", selectedDate );
	        $( "#tarih2" ).add( Validate.Presence );       
	      }
	    });
	    $( "#tarih2" ).datepicker({
	    	monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
	 	    monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz','Tem','Ağu','Eyl','Eki','Kas','Ara'],
	 	    dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
	 	    dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
	 	    dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
	 	    defaultDate: "+1w",
	        changeMonth: true,
	        numberOfMonths: 3,
	        dateFormat: 'dd/mm/yy',
	        onClose: function( selectedDate ) {
	        $( "#tarih1" ).datepicker( "option", "maxDate", selectedDate );
	        $( "#tarih1" ).add( Validate.Presence );
	      }
	    });
	    
	  });
	
	</script>
	<div class="contentTop">
		<div class="contentTopArea">
			<div id="formdiv">
				
				<p class="contentMainP">Arama Kriterleri</p>
				<hr noshade>
				
				<div id="form">
				
				<form>
<?php 
	if ($_SESSION['access_level'] != 50) {
	
?>				
				<label for="form1">Fakülte:</label>
				<select type="text" name="faculty_id" class="faculty_id">
				<option value="">Tüm Fakülteler</option>
<?php 
				$query = $_DB->Query("SELECT * from fen_faculty ORDER BY faculty_name ASC");
				$count = $_DB->GetResultNumber($query);
	
				for ($i=0; $i<$count; $i++)
				{
					
					echo "<option value=\"".$_DB->GetResultValue($query, $i, "id")."\">".$_DB->GetResultValue($query, $i, "faculty_name")."</option>";
				}
?>			
				</select><br>
<?php 
	}
?>
				<label for="form1">Bölüm:</label>
				<select type="text" name="department_id" class="department_id">
				<option value="">Tüm Bölümler</option>
<?php 
	if ($_SESSION['access_level'] == '50') {
		
		$query = $_DB->Query("SELECT * from fen_department WHERE faculty_id = (select faculty_id from fen_members where id = '".$_SESSION['user_id']."') ORDER BY department_name ASC");
		$count = $_DB->GetResultNumber($query);

		for ($i=0; $i<$count; $i++)
		{
		echo "<option value=\"".$_DB->GetResultValue($query, $i, "id")."\">".$_DB->GetResultValue($query, $i, "department_name")."</option>";
		}
		
	}
?>
				</select><br>
				
				<label for="form1">Öğretim Üyesi Adı:</label> <input type="text" id="name2" name="name" value=""><br>
				
				<label for="form1">Soyadı:</label> <input type="text" id="surname" name="surname" value=""><br>
								
				<label for="form1">Toplantı Adı:</label> <input type="text" id="toplanti_adi" name="toplanti_adi" value=""><br>
				
				<label for="form1">Bildiri Konusu:</label> <input type="text" id="bildiri_konusu" name="bildiri_konusu" value=""><br>
				
				<label for="form1">Ülke:</label>
				<select class="selectShort4" type="text" id="ulke" name="ulke">
				<option value="">Tüm Ülkeler</option>
	<?php 
				$query = $_DB->Query("SELECT ulke_name from fen_ulke ORDER BY ulke_name asc");
				$count = $_DB->GetResultNumber($query);
					
				for ($i=0; $i<$count; $i++)
				{
					echo "<option value=\"".$_DB->GetResultValue($query, $i, "ulke_name")."\">".$_DB->GetResultValue($query, $i, "ulke_name")."</option>";
				}
	
	?>			
						
				</select><br>
				
				<label for="form1">Toplantı Tarihi:</label> <input type="text" id="tarih1" name="tarih1" value="" readonly="readonly" placeholder="Başlangıç">&nbsp;<font color="#0289c5">-</color>&nbsp;<input type="text" id="tarih2" name="tarih2" value="" readonly="readonly" placeholder="Bitiş">
				<br>
				
				<label for="form1">İstenen Destek Türü:</label>
				<select class="selectShort4" type="text" id="destek_turu" name="destek_turu">
					<option value="">Tümü</option>
					<option value="Tam Destek">Tam Destek</option>
					<option value="Kısmi Destek">Kısmi Destek</option>			
				</select><br>
				
				<label for="form1">Ders Durumu:</label>
				<select class="selectShort4" type="text" id="ders_durumu" onChange="return setForm(this);" name="ders_durumu">
					<option value="">Tümü</option>
					<option value="Evet">Evet</option>
					<option value="Hayır">Hayır</option>			
				</select><br><br>

				<input id="buttonSaveNew" type="submit" value="Ara">
				</form>
				</div>
				<br><br>
			
			</div>
		</div>
	</div>
	<div class="contentMain">

		<div id="reportResult"><img src="images/spinner.gif" class="spinner" alt="loading..." style="display: none;"></div>
		<br><br><br><br><br><br></div>
		
	</div>

<?php
}